﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Web;

namespace weclever.Navigation
{
    public class WebCookieClient : WebClient 
    {
        private const int MaxAutomaticRedirections = 100;
        private CookieContainer _cookieConteiner = new CookieContainer();

        protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest httpWebRequest = base.GetWebRequest(address) as HttpWebRequest;
            if (httpWebRequest != null)
            {
                httpWebRequest.CookieContainer = _cookieConteiner;
                httpWebRequest.MaximumAutomaticRedirections = MaxAutomaticRedirections;
            }            
            return httpWebRequest;
        }
    }
}
